<html layout:decorator="public/layout" xmlns:miguo="http://www.w3.org/1999/html">
<div layout:fragment="content">

    <!-- 表格工具栏 -->
    <form class="layui-form toolbar">
        <div class="layui-form-item">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" name="tableName" placeholder="请输入表名称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" name="tableComment" placeholder="请输入表描述" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline" style="width: auto;">
                    <widget:btnQuery name="查询"/>
                    <widget:btnFunc name="确定|confirm|layui-icon-util|layui-bg-blue|1"/>
                </div>
            </div>
        </div>
    </form>

    <!-- 数据表格 -->
    <table class="layui-hide" id="tableList2" lay-filter="tableList2"></table>

    <script type="text/javascript">
        layui.use(['func'], function () {

            //声明变量
            var func = layui.func,
                $ = layui.$;

            //【TABLE列数组】
            var cols = [
                {type: 'checkbox', fixed: 'left'}
                , {field: 'tableName', width: 200, title: '表名称', align: 'left'}
                , {field: 'tableComment', width: 150, title: '表描述', align: 'center'}
                , {field: 'createTime', width: 180, title: '创建时间', align: 'center'}
            ];

            //【渲染TABLE】
            func.tableIns(cols, "tableList2", null, "/gentable/genDbTableList");

            // 确定按钮事件
            $(".btnConfirm").click(function () {
                var result = func.getCheckData("tableList2");
                if (result.length == 0) {
                    layer.msg("请至少选择一条记录", {icon: 5});
                    return false;
                }
                var arr = [];
                result.forEach(function (item, index) {
                    arr.push(item.tableName);
                });
                var data = {"tables": arr.join(",")};
                func.ajaxPost("/gentable/importTableSave", data, function (res, success) {
                    console.log("处理成功");
                    layer.closeAll("iframe");
                    // 刷新父页面
                    parent.location.reload();
                }, "处理中。。。");
            });
        });
    </script>
</div>
</html>